import React, { Component } from "react";
import './../taskmanage/Wofuzwderenwu.less'
import servies from "./../../servies";
import { Button, Form,  Select, Table, DatePicker, Space } from "antd";
const { Option } = Select;
const layout = {
  labelCol: {
    span: 8,
  },
  wrapperCol: {
    span: 16,
  },
};


export default class Taizhangguanli extends Component {
  constructor(props) {
    super(props);
    this.onChange = this.onChange.bind(this);
    this.state = {
      id: "",
      date: "",
      tzleibie: "",
      leixing: "",
      money: "",
      data:[],
    };
  }
  romref = React.createRef();
  formRef = React.createRef();
  
  componentDidMount() {
    //发起请求
   servies.GetTaizhangguanli().then((data)=>{
    console.log(data);
    this.setState({
      data:data
    })
   })
  }
  onReset = () => {
    this.formRef.current.resetFields();
  };
  onChange = (e) => {
    e.preventDefault()
    console.log("value", e.target.value);
    let key = e.target.dataset.key;
    this.setState({ [key]: e.target.value });
  };
  render() {
    const columns = [
      {
        title: "序号",
        dataIndex: "id",
        key: "id",
        fixed: "true",
        align: "center",
      },
      { 
        title: "日期",
        dataIndex: "date",
        key: "date",
        fixed: "true",
        align: "center",
      },
      {
        title: "台账类别",
        dataIndex: "tzleibie",
        key: "1",
        align: "center",
      },
      {
        title: "类型",
        dataIndex: "leixing",
        key: "2",
        align: "center",
      },
      {
        title: "交易金额(万元)",
        dataIndex: "money",
        key: "3",
        align: "center",
      },
      {
        title: "操作",
        key: "operation",
        fixed: "true",
        render: () => <span className="actions">查看详情</span>,
        align: "center",
      },
    ];
    return (
      <>
        <Form
          {...layout} ref={this.formRef} name="control-ref"  onFinish={this.onFinish} >
          <Form.Item name="date" label="时间">
            <Space direction="vertical">
              <DatePicker placeholder="" />
            </Space>
          </Form.Item>
          <Form.Item name="tzleibie" label="台账类别">
            <Select allowClear onChange={this.onGenderChange} defaultValue="male" >
              <Option value="male">全部</Option>
              <Option value="female">进项</Option>
              <Option value="other">出项</Option>
            </Select>
          </Form.Item>
          <Form.Item name="leixing" label="类型">
            <Select allowClear onChange={this.onGenderChange} defaultValue="male" >
              <Option value="male">全部</Option>
              <Option value="female">班组付款</Option>
              <Option value="cailiao">材料采购付款</Option>
              <Option value="hetong">项目合同收款</Option>
              <Option value="linshi">临时付款</Option>
              <Option value="renli">人力工资付款</Option>
            </Select>
          </Form.Item>
        </Form>
         <div className="ant-btn-block">
            <Button type="primary" htmlType="submit">查询</Button>
            <Button htmlType="button" onClick={this.onReset}>重置</Button>
            </div>
      <Table columns={columns} dataSource={this.state.data} scroll={{}} />
      </>
    );
  }
}


